# coding=utf-8
var1 = 'hello world!'
var2 = "python programming"
var3 = '''hello chuanzhiboke'''
var4 = """hello chuanzhiboke"""
print var1, var2, var3, var4
print "hello \"dear\""
print 'hello "dear"'
print "hello 'dear'"
print '''hello "dear"'''
print '''"hello 'dear'"'''
print """hello 'dear'"""
print """'hello "dear"'"""
print '''
line 1
line 2
'''
var5 = "hello world itcast"
print var5
for s in var5:
    print s
print var5[0]
print var5[1:]
print var5[6:11]
print type(var5)
print  "var5_id:", id(var5)
var6 = var5
var5 = 'chuanzhiboke'
print var5
print "var5_id:", id(var5)
print "var6_id:", id(var6)
print '*' * 20
print 'e' in 'es'
print 'e' not in 'es'
print 'hello\n\n'
print r'hello\n\n'
print "my name is %s and weight is %d" % ('cpp', 2)
# 字符串的函数
mystr = 'hello world itcast and itcastcpp and itcast'
print mystr.find('itcast')
print mystr[12:]
print mystr[mystr.find('itcast', 13):]
print mystr.find('itcast', 0, len(mystr))
print mystr.index('itcast')
print mystr.count('itcast', 0, len(mystr))
var2 = mystr.decode(encoding='UTF-8')
print var2
print type(var2)
# erros: strict ignore replace
var2 = mystr.decode(encoding='UTF-8', errors='strict')
mystr = mystr.replace('itcast', 'chuanzhiboke')
print mystr
mystr = mystr.replace('chuanzhiboke', 'itcast')
print mystr.replace('chuanzhiboke', 'itcast')
print mystr.replace('itcast', 'chuanzhiboke', 2)
print '-' * 10
mylist = mystr.split(' ')
for key in mylist:
    print key
print '-' * 10
mylist1 = mystr.split(' ', 3)
for key in mylist1:
    print key
print '-' * 10
mylist.sort()
print mylist
print '-' * 10
print mystr.capitalize()
print mystr.center(50, ' ')
print mystr.endswith('itcast')
print mystr.startswith('hello')
print '-' * 10
print mystr.isalnum()
print 'hello1'.isalnum()
print '-'*10, 'isdecimal'
print '123'.decode(encoding='utf-8').isdecimal()
print '123'.isdigit()
print 'abc'.isalpha()
print ' '.isspace()
var1 = 'hello'
print var1.join('xxx')
print var1.ljust(10, '-')
print var1.rjust(10, '-')
var1 = '     hello     '
print '"', var1, '"'
print '"', var1.lstrip(), '"'
print '"', var1.rstrip(), '"'
print '"', var1.strip(), '"'
print mystr.partition('hello')
print mystr.partition('world')
print mystr.partition('itcast')
print mystr.rpartition('itcast')
print 'hello'.zfill(10)
